import abc

from frozendict import frozendict


class Mergeable(abc.ABC):
    @property
    def merging_signature(self) -> frozendict:
        return get_default_merging_signature(self)


def get_default_merging_signature(obj) -> frozendict:
    return frozendict(type="object", id=id(obj))


def get_merging_signature(obj) -> frozendict:
    return obj.merging_signature if isinstance(obj, Mergeable) else get_default_merging_signature(obj)


def check_mergeable(obj0, obj1) -> bool:
    sig0 = get_merging_signature(obj0)
    sig1 = get_merging_signature(obj1)
    return sig0 == sig1
